package com.saturn.titan.web.controller;

import java.text.ParseException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.saturn.titan.core.bean.BusiInstallBill;
import com.saturn.titan.core.service.RepairAndInstallBillService;

/**
 * @author liuwenhao
 */
@Controller
@RequestMapping(value = "/installBill")
public class InstallBillController extends BaseController{

	@Autowired
	private RepairAndInstallBillService repairAndInstallBillService;
	
	@RequestMapping(value = "selectInstallBill")
	@ResponseBody
	public  List<BusiInstallBill> selectInstallBill(@RequestParam(value="customerPhone") String customerPhone,
			@RequestParam(value="billStt") Integer billStt ,
			@RequestParam(value="deployEmpName") String deployEmpName ,
			@RequestParam(value="emergentType") Integer emergentType,
			@RequestParam(value="page") Integer page,
			@RequestParam(value="rows") Integer rows
			) throws ParseException {
		BusiInstallBill bill = new BusiInstallBill();
		if(null!=customerPhone && customerPhone.length()>0){
			bill.setCustomerPhone(customerPhone);
		}
		if(null != deployEmpName && !deployEmpName.trim().equals("")){
			bill.setDeployEmpName(deployEmpName);
		}
		if(null!=billStt){
			bill.setBillStt(billStt);
		}
		if(null!=emergentType){
			bill.setEmergentType(emergentType);
		}
		
		int beginIndex = (page-1) * rows;
		bill.setStart(beginIndex);
		bill.setSize(rows);
		
		List<BusiInstallBill> result = repairAndInstallBillService.selectInstallBillList(bill);
		
		return result;
	}
	
}
